package digital.store.springmvc.service;

import java.util.Collection;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

 


import org.springframework.transaction.annotation.Transactional;

import digital.store.springmvc.dao.ProductDao;
import digital.store.tutorial.springmvc.model.Product;

@Service
@Transactional
public class ProductService {
    @Autowired
    private ProductDao productDao;
    
    @Transactional
    public void saveOrUpdate(Product product) {
    	productDao.saveOrUpdate(product);
    }
    
    @Transactional
    public void delete(Long productId) {
        productDao.delete(productId);
    }
    
    
    public Collection<Product> findAll() {
        return productDao.findAll();
    }
    
 
    public Product findById(Long productId) {
        return productDao.findById(productId);
    }
   
    public Collection<Product> findByCategoryId(Long categoryId){
    	return productDao.findByCategoryId(categoryId);
    }
}
